package m1.server.config.connector;

import m1.server.config.connector.glue.ClearanceRequestGlue;
import m1.server.config.connector.role.Grantor;
import m1.server.config.connector.role.ReceiveRequestorSecurityCheck;
import m1.server.config.connector.role.RequestorSecurityCheck;
import m1.server.config.connector.role.SendGrantor;
import m2.connector.Connector;

public class ClearanceRequest extends Connector{

	private static ClearanceRequest clearanceRequest = null;
	
	private ClearanceRequest(){
		addGlueIn(new ClearanceRequestGlue());
		addGlueOut(new ClearanceRequestGlue());
		
		RequestorSecurityCheck requestorSecurityCheck = new RequestorSecurityCheck();
		SendGrantor sendGrantor = new SendGrantor();
		ReceiveRequestorSecurityCheck receiveRequestorSecurityCheck = new ReceiveRequestorSecurityCheck();
		Grantor grantor = new Grantor();
				
		addRequiredRole(requestorSecurityCheck, sendGrantor);
		addProvidedRole(receiveRequestorSecurityCheck, grantor);
		
		((ClearanceRequestGlue)getGlueIn()).clearanceRequestConnectRequiredRoleToProvidedRole(requestorSecurityCheck, grantor);
		((ClearanceRequestGlue)getGlueOut()).clearanceRequestConnectRequiredRoleToProvidedRole(sendGrantor, receiveRequestorSecurityCheck);
	}
	
	/**
	 * 
	 * @return
	 */
	public static ClearanceRequest getInstance(){
		if (clearanceRequest == null){
			clearanceRequest = new ClearanceRequest();
		}
		return clearanceRequest;
	}
}
